package org.tom.pay.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.tom.basic.service.impl.BaseServiceImpl;
import org.tom.pay.domain.PayBill;
import org.tom.pay.mapper.PayBillMapper;
import org.tom.pay.service.IPayBillService;

import java.math.BigDecimal;
import java.util.Date;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class PayBillServiceImpl extends BaseServiceImpl<PayBill> implements IPayBillService {

    @Autowired
    private PayBillMapper payBillMapper;

    @Override
    @Transactional
    public void savePayBill(Long id, Integer petBuy, Date createTime, String name, BigDecimal totalPrice, Long logininfoId, String username, Integer payType, Long shopId, String shopName, int waitPayOrder, String sn) {
        PayBill payBill = new PayBill();
        payBill.setDigest("购买："+ name);
        payBill.setMoney(totalPrice);
        payBill.setState(PayBill.WAIT_PAY);
        payBill.setCreateTime(createTime);
        payBill.setPayChannel(payType);
        payBill.setUnionPaySn(sn);
        payBill.setBusinessType(waitPayOrder);
        payBill.setBusinessKey(id);
        payBill.setUser_id(logininfoId);
        payBill.setNickName(username);
        payBill.setShop_id(shopId);
        payBill.setShopName(shopName);


        payBillMapper.add(payBill);
    }
}
